Repeat elememts based on another elements in the nested list